package tv.acgn.advertisement.publish.validator;

import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;

import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @program: advertisement-ad-pub-validator
 * @description: Validator 参数校验器 配置
 * @author: junG
 * @create: 2019-05-01 17:35
 **/

@Configuration
public class ValidatorConfiguration {
    @Bean
    public Validator validator(){
        /**
         * 配置校验属性
         * 使用普通模式
         * 通过全部校验器后一次性返回所有信息
         */
        ValidatorFactory validatorFactory = Validation.byProvider( HibernateValidator.class )
                .configure()
                .addProperty( "hibernate.validator.fail_fast", "false" )
                .buildValidatorFactory();
        Validator validator = validatorFactory.getValidator();

        return validator;
    }
}
